package xyz.wanhongtao.smtpclient.service;

import org.springframework.stereotype.Service;
import xyz.wanhongtao.smtpclient.object.form.UserLoginForm;
import xyz.wanhongtao.smtpclient.object.form.UserRegistryForm;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author wanghongtao <wanghongtao05@kuaishou.com>
 * Created on 2023-07-03
 */
@Service
public class UserService {
    private static final Map<String, String> users = new ConcurrentHashMap<>();

    static {
        //换成自己的账号密码
        users.put("1946066280@qq.com", "123456");
    }

    //登陆
    public Boolean login(UserLoginForm loginForm) {
        if (!users.containsKey(loginForm.getEmail())) return false;
        return users.get(loginForm.getEmail()).equals(loginForm.getPassword());
    }

    //注册
    public Boolean registry(UserRegistryForm registryForm) {
        users.put(registryForm.getEmail(), registryForm.getPassword());
        return users.containsKey(registryForm.getEmail());
    }
}
